package com.khtn.model;

import java.io.Serializable;

import javax.persistence.*;

import org.json.simple.JSONObject;

import java.util.List;


/**
 * The persistent class for the types database table.
 * 
 */
@Entity
@Table(name="types")
@NamedQuery(name="Type.findAll", query="SELECT t FROM Type t")
public class Type extends AbstractModel implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@Column(name="type_id")
	private int typeId;

	@Column(name="type_name")
	private String typeName;

	@Column(name="type_order")
	private int typeOrder;

	@Column(name="type_parent_id")
	private int typeParentId;

	@Column(name="type_type")
	private String typeType;

	//bi-directional many-to-one association to Tour
	@OneToMany(mappedBy="type1")
	private List<Tour> tours1;

	//bi-directional many-to-one association to Tour
	@OneToMany(mappedBy="type2")
	private List<Tour> tours2;

	//bi-directional many-to-one association to Tour
	@OneToMany(mappedBy="type3")
	private List<Tour> tours3;

	public Type() {
	}

	public int getTypeId() {
		return this.typeId;
	}

	public void setTypeId(int typeId) {
		this.typeId = typeId;
	}

	public String getTypeName() {
		return this.typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	public int getTypeOrder() {
		return this.typeOrder;
	}

	public void setTypeOrder(int typeOrder) {
		this.typeOrder = typeOrder;
	}

	public int getTypeParentId() {
		return this.typeParentId;
	}

	public void setTypeParentId(int typeParentId) {
		this.typeParentId = typeParentId;
	}

	public String getTypeType() {
		return this.typeType;
	}

	public void setTypeType(String typeType) {
		this.typeType = typeType;
	}

	public List<Tour> getTours1() {
		return this.tours1;
	}

	public void setTours1(List<Tour> tours1) {
		this.tours1 = tours1;
	}

	public Tour addTours1(Tour tours1) {
		getTours1().add(tours1);
		tours1.setType1(this);

		return tours1;
	}

	public Tour removeTours1(Tour tours1) {
		getTours1().remove(tours1);
		tours1.setType1(null);

		return tours1;
	}

	public List<Tour> getTours2() {
		return this.tours2;
	}

	public void setTours2(List<Tour> tours2) {
		this.tours2 = tours2;
	}

	public Tour addTours2(Tour tours2) {
		getTours2().add(tours2);
		tours2.setType2(this);

		return tours2;
	}

	public Tour removeTours2(Tour tours2) {
		getTours2().remove(tours2);
		tours2.setType2(null);

		return tours2;
	}

	public List<Tour> getTours3() {
		return this.tours3;
	}

	public void setTours3(List<Tour> tours3) {
		this.tours3 = tours3;
	}

	public Tour addTours3(Tour tours3) {
		getTours3().add(tours3);
		tours3.setType3(this);

		return tours3;
	}

	public Tour removeTours3(Tour tours3) {
		getTours3().remove(tours3);
		tours3.setType3(null);

		return tours3;
	}

	@Override
	public JSONObject toJson() {
		JSONObject js = new JSONObject();
//		js.put("type_id", getTourId());
//		js.put("tour_name", getTourName());
//		js.put("tour_content", getTourContent());
//		js.put("tour_price", getTourPrice());
//		js.put("tour_date_begin", getTourDateBegin());
//		js.put("tour_date_end", getTourDateEnd());
//		js.put("tour_count", getTourCount());
		return js;
	}

}